home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8499 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: chronicle.mti.sgi.com!news
  2. From: austern@isolde.mti.sgi.com (Matt Austern)
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Performance: C vs. C++
  5. Followup-To: comp.lang.c++,comp.lang.c
  6. Date: 15 Feb 1996 21:43:14 GMT
  7. Organization: SGI
  8. Message-ID: <AUSTERN.96Feb15134314@isolde.mti.sgi.com>
  9. References: <30F6BAAC.12B5@iastate.edu> <4da9pn$a45@news.bridge.net>
  10.     <4dnpl2$c8g@classic.iinet.com.au> <3105E9DC.1BE3@enermet.fi>
  11.     <DLr46y.7rH@txnews.amd.com> <4elk5l$3f2q@yuma.ACNS.ColoState.EDU>
  12.     <pronet01.31.003EB1E6@indirect.com> <3117F980.7890@hpato.aus.hp.com>
  13.     <4fgd62$asb@gaia.ns.utk.edu> <4frur0$73t@adam.telalink.net>
  14.     <4fvr7k$a3l@stc06.ctd.ornl.gov>
  15. Reply-To: austern@mti.sgi.com
  16. NNTP-Posting-Host: isolde.mti.sgi.com
  17. In-reply-to: kennel@msr.epm.ornl.gov's message of 15 Feb 1996 17:41:08 GMT
  18.  
  19. In article <4fvr7k$a3l@stc06.ctd.ornl.gov> kennel@msr.epm.ornl.gov (Matt Kennel) writes:
  20.  
  21. > > What is a "dispatched pointer"?
  22. > In C++ it would be a pointer to a base class which has 'virtual members',
  23. > where the particular function called is chosen by the actual run-time 
  24. > type. 
  25. > In C++, if you have a pointer, then it is always conceivably dispatched,
  26. > unless everything in the class is declared "static".   
  27. > So here "reference semantics" (going through a pointer, a storage area 
  28. > potentially aliased) are joined with "dispatchability".
  29.  
  30. That's not quite true.  In C++, a function call is dispatched only if
  31. the function is declared as virtual in the base class.  You don't have
  32. to make any special declaration of a function to make it
  33. non-dispatched; you simply have to avoid doing anything special.
  34. Declaring a function to be static is something else entirely.
  35.  
  36. And if you do have a pointer to a polymorphic class, and you want to
  37. call a virtual function and ensure that you're calling the base 
  38. class's version, that's actually possible: instead of writing
  39. base_pointer->f(), you write base_pointer->base::f().  The syntax
  40. is ugly, to be sure, but it doesn't bother me that you have to use
  41. ugly syntax for such a rare operation.
  42. -- 
  43. Matt Austern
  44. SGI: MTI Compilers Group
  45. austern@isolde.mti.sgi.com
  46.